package com.example.lp.lpuicore.paint.model;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.util.Log;

/**
 * Author by lp,on 2021/6/17/017,14:27.
 */
public class LinearRendering implements IPaintModel {
    @Override
    public void draw(Canvas canvas, Paint paint) {
        Log.i("LinearRendering", "LinearRendering: ");
        /**
         * 1.线性渲染,LinearGradient(float x0, float y0, float x1, float y1, @NonNull @ColorInt int colors[], @Nullable float positions[], @NonNull TileMode tile)
         * (x0,y0)：渐变起始点坐标
         * (x1,y1):渐变结束点坐标
         * color0:渐变开始点颜色,16进制的颜色表示，必须要带有透明度
         * color1:渐变结束颜色
         * colors:渐变数组
         * positions:位置数组，position的取值范围[0,1],作用是指定某个位置的颜色值，如果传null，渐变就线性变化。
         * tile:用于指定控件区域大于指定的渐变区域时，空白区域的颜色填充方法
         */
        LinearGradient  mShader = new LinearGradient(0, 0, 300, 300, new int[]{Color.RED, Color.BLUE, Color.GREEN}, new float[]{0.f, 0.7f, 1}, Shader.TileMode.REPEAT);
        paint.setShader(mShader);
//        canvas.drawCircle(250, 250, 250, mPaint);
        canvas.drawRect(0, 0, 300, 300, paint);
    }
}
